<?php
 include('../libary/init_admin.php');
 if (isset($_GET['infosong'])) 
 {
	 $id=$_GET['infosong'];
	 $cmd="SELECT * FROM `tmp` WHERE tmp_id=".$id;
	 $info=mysql_fetch_assoc(mysql_query($cmd)); 
echo'
<div id="space"><div class="duyetpress"><button type="submit" name="submit">Duyệt</button></div></div>
<div id="space"><div class="buttons"><a href="export.php?idsave='.$info['tmp_id'].'" class="button save">Lưu</a></div></div>
<div id="space"><div class="buttons"><a href="?menu=upmedia&del='.$info['tmp_id'].'" class="button delete">Xóa</a></div></div>
<div class="space"></div>
<div id="mediainfox">';	
     echo'<div class="selecttitle22"><a><b>NGHE THỬ BÀI HÁT</b></a></div>';
	 $link=$info['tmp_link'];
	 $audiocheck=false;
	 $videocheck=false;
	 $exten=substr($link,strlen($link)-3,strlen($link));
	if (($exten=='mp3') || ($exten=='MP3')) $audiocheck=true; else
	 $videocheck=true;
	 if ($videocheck)
	{
	echo '
<script type="text/javascript" type="text/javascript" src="../template/script/js/player.js">		</script>
<div id="mediaspace"></div>';
echo"
<script type='text/javascript'>
  jwplayer('mediaspace').setup({
    'flashplayer': 'http://beta.cailuongso.com/media/player.swf',
    'file': '".$info['tmp_link']."',
    'controlbar': 'bottom',
	'autostart': 'true',
	'plugins': 'hd-1',
    'width': '305',
    'height': '195'
  });
</script>";
	}
    if ($audiocheck)
	{
	echo'
<script type="text/javascript" type="text/javascript" src="../template/script/js/player.js"></script>
<div id="mediaspace"></div>';
echo"
<script type='text/javascript'>
  jwplayer('mediaspace').setup({
    'flashplayer': 'http://beta.cailuongso.com/media/player.swf',
    'file': 'http://beta.cailuongso.com/".$link."',
    'controlbar': 'bottom',
	'autostart': 'true',
    'width': '255',
    'height': '22'
  });
</script>";
		}
	echo '<br/>';
    $curdir=getcwd();
	chdir('/home/cailuong/public_html/beta/');
	$getID3 = new getID3;
	$mediainfo = $getID3->analyze($info['tmp_link']);
	$sizef=$mediainfo['filesize'];
	$bitrate=$mediainfo['bitrate'];
	$playtime=$mediainfo['playtime_string'];
		
	chdir($curdir);	
	echo'
	<div class="selecttitle2"><a><b>THÔNG TIN THÀNH VIÊN CUNG CẤP</b></a></div>
	<table border="0">
	<tr>
    <td width="70px"><div class="selecttitle2"><a>Tình trạng</a></div></td>
    <td><div class="selecttitle2"><a><select name="songstatus">';
		echo '<option value="0">Chưa có dữ liệu</option>
		<option value="1">Còn thiếu dữ liệu</option>
		<option value="2">Dữ liệu đã đầy đủ</option>';		
	echo'</select></a></div></td>
    </tr>
    <tr>
    <td><div class="selecttitle2"><a>Tên bài hát</a></div></td>
    <td><div class="selecttitle2"><a><input name="songname" type="text" value="'.$info['tmp_name'].'"/>   </a></div></td>
    </tr>
	<tr> 
    <td><div class="selecttitle2"><a>Tên File</a></div></td>
    <td><div class="selecttitle2"><a><input name="songfile" type="text" value="'.$info['tmp_file'].'"/>   </a></div></td>
    </tr>
	<tr>
    <td><div class="selecttitle2"><a>Dung lượng</a></div></td>
    <td><div class="selecttitle2"><a><input name="sizef" type="text" value="'.round($sizef/(1024*1024),2).' MB"/></a></div></td>
	</tr>
	<tr>
	<td><div class="selecttitle2"><a>Bitrate</a></div></td>
    <td><div class="selecttitle2"><a><input name="bitrate" type="text" value="'.round($bitrate/1000,0).' kb/s"/></a></div></td>
    </tr>
	<tr>
	<td><div class="selecttitle2"><a>Playtime</a></div></td>
    <td><div class="selecttitle2"><a><input name="playtime" type="text" value="'.$playtime.'"/></a></div></td>
    </tr>
	<tr>
    <td><div class="selecttitle2"><a>Nghệ sĩ</a></div></td>
    <td><div class="selecttitle2"><a><input type="text" value="'.$info['tmp_artist'].'"/></a></div></td>
    </tr>
	<tr>
    <td><div class="selecttitle2"><a>Soạn giả</a></div></td>
    <td><div class="selecttitle2"><a><input type="text" value="'.$info['tmp_author'].'"/></a></div></td>
    </tr>
    <tr>
    <td><div class="selecttitle2"><a>Thể loại</a></div></td>
    <td><div class="selecttitle2"><a><select name="songtype">';
	$cmd="SELECT * FROM `cat`";	
	$excute=mysql_query($cmd);
	while ($info2=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
		$value=$info2['cat_id'];
		if ($value==$info['tmp_cat']) $show="selected"; else $show='';
		echo '<option value="'.$value.'" '.$show.'>'.$info2['cat_name'].'</option>';
	}
	echo'</select></a></div></td>
    </tr>';
	if ($videocheck)
	{ echo '
    <tr>
    <td><div class="selecttitle2"><a>Link Video</a></div></td>
    <td><div class="selecttitle2"><a><input name="linkvideo" type="text"/></a></div></td>
    </tr>';
	}
	echo '</table>';
	if ($videocheck)
	{ echo '	
	<div class="selecttitle2"><a>Tải ảnh video lên &nbsp;&nbsp;<input type="file" name="file" id="file"/><a>';
	}
	echo'
	<br/>
	</div>
	<div class="selecttitle2"><a><b>Lời nhạc</b><br/><br/><textarea name="info"></textarea><a></div>
	<div id="data" style="display: none;">
		<input name="linkvideo" type="text" value="'.$info['tmp_youtube'].'"/>
		<input name="linkfile" type="text" value="'.$info['tmp_link'].'"/>
		<input name="thisid" type="text" value="'.$info['tmp_id'].'"/>
		<input name="poster" type="text" value="'.$info['tmp_poster'].'"/>
		<input name="time" type="text" value="'.$info['tmp_time'].'"/>
	</div>
	';	
	
 }else 
 if (isset($_GET['mstatus'])&&isset($_GET['mid']))
 {
	 $status=$_GET['mstatus'];
	 $id=$_GET['mid'];
	 $cmd='UPDATE `module` SET module_status='.$status.' WHERE module_id='.$id.'';
	 mysql_query($cmd);
	 if ($status==1) echo 'Đã bật '.$id; else echo 'Đã tắt '.$id;
 }else
 header('location:/');
?>